This patch adds a quick check to 'xm restore' that checks the
authoremellor@ewan <emellor@ewan>
Tue, 27 Sep 2005 14:10:38 +0000 (15:10 +0100)
committeremellor@ewan <emellor@ewan>
Tue, 27 Sep 2005 14:10:38 +0000 (15:10 +0100)
existence and readability of the file given.

This fixes the issue detected in xm-tests 03_restore_badparm_neg and
04_restore_badfilename_neg.

Signed-off-by: Dan Smith <danms@us.ibm.com>
Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/python/xen/xm/main.py

index 0db2e8636de1382cee39276c50f501a5288736d0..648c5968a7f725e2054a72fd1e135866d3aaab9c 100644 (file)
@@ -188,6 +188,10 @@ def xm_restore(args):
 
     savefile = os.path.abspath(args[0])
 
+    if not os.access(savefile, os.R_OK):
+        err("xm restore: Unable to read file %s" % savefile)
+        sys.exit(1)
+
     from xen.xend.XendClient import server
     info = server.xend_domain_restore(savefile)
     PrettyPrint.prettyprint(info)